package com.xhwy.vo;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.xhwy.entity.Product;
import com.xhwy.entity.ShoppingCart;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;
import java.math.BigDecimal;

@JsonIgnoreProperties(ignoreUnknown = true)
@Data
@NoArgsConstructor
public class ShoppingCartVo implements Serializable {

    private Integer shoppingCartId; //购物车id
    private Integer productId;  //商品id
    private String productName; //商品名称
    private String mainImage; //商品图片
    private Double marketPrice; //市场价
    private Double promotionPrice; //促销价
    private Integer num; //商品加购数量
    private Integer maxNum; //商品限购数量
    private Boolean check = false; //是否勾选

    public ShoppingCartVo(Product product, ShoppingCart cart){
        this.shoppingCartId = cart.getShoppingCartId();
        this.productId = product.getProductId();
        this.productName = product.getProductName();
        this.mainImage = product.getMainImage();
        this.marketPrice = product.getMarketPrice();
        this.promotionPrice = product.getPromotionPrice();
        this.num = cart.getProductNumber();
        this.maxNum = product.getInventory();
        this.check = false;
    }
}
